package com.ruoyi.coupons.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.coupons.mapper.CouponsMapper;
import com.ruoyi.coupons.domain.Coupons;
import com.ruoyi.coupons.service.ICouponsService;

/**
 * 优惠券Service业务层处理
 *
 * @author ruoyi
 * @date 2021-11-24
 */
@Service
public class CouponsServiceImpl implements ICouponsService
{
    @Autowired
    private CouponsMapper couponsMapper;

    /**
     * 查询优惠券
     *
     * @param id 优惠券主键
     * @return 优惠券
     */
    @Override
    public Coupons selectCouponsById(Long id)
    {
        return couponsMapper.selectCouponsById(id);
    }

    /**
     * 查询优惠券列表
     *
     * @param coupons 优惠券
     * @return 优惠券
     */
    @Override
    public List<Coupons> selectCouponsList(Coupons coupons)
    {
        return couponsMapper.selectCouponsList(coupons);
    }

    /**
     * 新增优惠券
     *
     * @param coupons 优惠券
     * @return 结果
     */
    @Override
    public int insertCoupons(Coupons coupons)
    {
        coupons.setCreateTime(DateUtils.getNowDate());
        return couponsMapper.insertCoupons(coupons);
    }

    /**
     * 修改优惠券
     *
     * @param coupons 优惠券
     * @return 结果
     */
    @Override
    public int updateCoupons(Coupons coupons)
    {
        coupons.setUpdateTime(DateUtils.getNowDate());
        return couponsMapper.updateCoupons(coupons);
    }

    /**
     * 批量删除优惠券
     *
     * @param ids 需要删除的优惠券主键
     * @return 结果
     */
    @Override
    public int deleteCouponsByIds(Long[] ids)
    {
        return couponsMapper.deleteCouponsByIds(ids);
    }


    /**
     * 批量逻辑删除优惠券
     *
     * @param ids 需要删除的优惠券主键
     * @return 结果
     */
    @Override
    public int logicDeleteCoupons(Long[] ids,String delType,Long delUser)
    {
        return couponsMapper.logicDeleteCoupons(ids,delType,delUser);
    }

    /**
     * 删除优惠券信息
     *
     * @param id 优惠券主键
     * @return 结果
     */
    @Override
    public int deleteCouponsById(Long id)
    {
        return couponsMapper.deleteCouponsById(id);
    }

    @Override
    public int shelve(Long id, String state) {
        return couponsMapper.shelve(id,state);
    }

    @Override
    public List<Coupons> selectNeedOverdue() {
        return couponsMapper.selectNeedOverdue();
    }
}
